package com.cn.crmsystem.controller.approveController;

import com.cn.crmsystem.pojo.*;
import com.cn.crmsystem.service.approveService.OverTimeService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@Controller
@Api(value = "加班api",tags = "加班API")
public class OverTimeController {
	@Autowired OverTimeService overTimeService;
	//查询
	@RequestMapping(value = "/SelectOverTime",name = "加班查询",method = RequestMethod.POST)
	@ApiOperation(value = "查询加班申请",notes = "查询",httpMethod = "POST", response = String.class)
	@ApiImplicitParams({
			@ApiImplicitParam(name = "userid",value = "用户id",paramType = "query",dataType = "Integer",required = false),
			@ApiImplicitParam(name = "method",value = "我发出的还是我审核",paramType = "query",dataType = "String",required = false)
	})
	@ResponseBody
	public  ResultJson selectOverTime(@RequestParam(name = "userid") Integer userid,
									@RequestParam(name = "method") String method){
		ResultJson resultJson=new ResultJson();
		resultJson=overTimeService.SelectMyOverTime(userid,method);
		return resultJson;
	}
	//修改
	@RequestMapping(value = "/OverTimeUpdate",name = "加班修改",method = RequestMethod.POST)
	@ApiOperation(value = "修改加班申请",notes = "更新",httpMethod = "POST", response = String.class)
	@ApiImplicitParams({
			@ApiImplicitParam(name = "appid",value = "审核id",paramType = "query",dataType = "Integer",required = false),
			@ApiImplicitParam(name = "state",value = "状态",paramType = "query",dataType = "Integer",required = false)
	})
	@ResponseBody
	public  ResultJson OverTimeUpdate(@RequestParam(name = "appid") Integer appid,
									  @RequestParam(name = "state") Integer state){
		ResultJson resultJson=new ResultJson();
		resultJson=overTimeService.UpdateOverTime(appid,state);
		return  resultJson;
	}
	//删除
	@RequestMapping(value = "/DeleteOverTime",name = "加班删除",method = RequestMethod.POST)
	@ApiOperation(value = "删除加班申请",notes = "更改deleteid",httpMethod = "POST", response = String.class)
	@ApiImplicitParams({
			@ApiImplicitParam(name = "userid",value = "审核id",paramType = "query",dataType = "Integer",required = false)
	})
	@ResponseBody
	public  ResultJson DeleteOverTime(@RequestParam(name = "userid") Integer appid){
		ResultJson resultJson=new ResultJson();
		resultJson=overTimeService.DeleteOverTime(appid);
		return  resultJson;
	}
	//查询审核人
	@RequestMapping(value = "/selectOverTimeLeader",name = "加班查询审核人",method = RequestMethod.POST)
	@ApiOperation(value = "查询审核人",notes = "查询领导人",httpMethod = "POST", response = String.class)
	@ApiImplicitParams({
			@ApiImplicitParam(name = "userid",value = "用户id",paramType = "query",dataType = "Integer",required = false)
	})
	@ResponseBody
	public  ResultJson selectOverTimeLeader (@RequestParam(name = "userid")  Integer userid){
		ResultJson resultJson=new ResultJson();
		resultJson=overTimeService.selectLeader(userid);
		return  resultJson;
	}
	//增加
	@RequestMapping(value = "/InsertOverTime",name = "加班增加",method = RequestMethod.POST)
	@ApiOperation(value = "新增加班申请",notes = "插入",httpMethod = "POST", response = String.class)
	@ResponseBody
	public  ResultJson InsertOverTime (@RequestBody
										   @ApiParam(name = "删除",value = "删除",required = false)	Approve AP){
		ResultJson resultJson=new ResultJson();
		Integer leader=AP.getLeader_Id();
		Overtime overtime=AP.getOvertime();
		resultJson=overTimeService.OverTimeInsert(overtime,leader);
		return  resultJson;
	}
	//条件查询
	@RequestMapping(value = "/SelectConditionOverTime",name = "加班条件查询",method = RequestMethod.POST)
	@ApiOperation(value = "筛选",notes = "条件查询查询",httpMethod = "POST", response = String.class)
	@ApiImplicitParams({
			@ApiImplicitParam(name = "userid",value = "用户id",paramType = "query",dataType = "Integer",required = false),
			@ApiImplicitParam(name = "state",value = "审核状态",paramType = "query",dataType = "Integer",required = false),
			@ApiImplicitParam(name = "method",value = "我发出的还是我审核",paramType = "query",dataType = "String",required = false)
	})
	@ResponseBody
	public  ResultJson SelectConditionOverTime(@RequestParam(name = "userid") Integer userid,
											@RequestParam(name = "state") String method,
											@RequestParam(name = "method") String state ){
		ResultJson resultJson=new ResultJson();
		resultJson=overTimeService.SelectConditionOverTime(userid,method,state);
		return resultJson;
	}
}
